# -*- coding: utf-8 -*-
"""
计算数组的和，使用liner recursion
"""
from typing import Sequence


def liner_sum(S: Sequence[int], n: int):
    """Return the sum of the first n numbers of sequence S."""
    if n == 0:
        return 0
    else:
        return liner_sum(S,n-1) + S[n-1]


if __name__ == "__main__":
    tmp_list = [1,2,3,4,5]
    ret = liner_sum(tmp_list,len(tmp_list))
    print(ret)